﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Rhino.Mocks;

namespace ValidationFramework.Tests
{
	[TestFixture]
	public class RuleTests
	{
		public class FakeValidator : ISpecification
		{

			#region ISpecification Members

			public string DefaultMessage(string targetName, string descriptorType)
			{
				throw new NotImplementedException();
			}

			public string GetInterpretation()
			{
				throw new NotImplementedException();
			}

			public bool IsSatisfiedBy(object target)
			{
				throw new NotImplementedException();
			}

			public bool CanBeSatisfiedBy(Type type)
			{
				throw new NotImplementedException();
			}

			public bool IsEquivalentTo(ISpecification spec)
			{
				throw new NotImplementedException();
			}

			#endregion
		}
		[Test]
		public void IsEquivalent_DifferentValidatorTypes_WillAssumeFalseToAvoidPotentialRuntimeCastingExceptions()
		{
			// arrange
			var mockValidator = MockRepository.GenerateMock<ISpecification>();
			var fakeValidator = new FakeValidator();

			var ruleOne = new Rule(mockValidator);
			var ruleTwo = new Rule(fakeValidator);
				 
			// act
			var result = ruleOne.IsEquivalent(ruleTwo);

			// assert
			Assert.IsFalse(result);
			mockValidator.AssertWasNotCalled(x => x.IsEquivalentTo(fakeValidator));
		}
	}
}
